#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define	SEP	(',')

//----------------------------------------------------------
typedef struct s_bignum
{
	char *val;
	int len;
	int sem_pos;
	char sign;
} bignum;
//----------------------------------------------------------
bignum *bignum_make_zero()
{
	bignum *ret;
	ret = malloc(sizeof(bignum));
	memset(ret, 0, sizeof(bignum));
	return ret;
}
//----------------------------------------------------------
void bignum_remove_zeros(bignum *n)
{
	int lz=0, rz=0, i = 0, j;
	for(;n->val[rz]==0&&rz<n->sem_pos;rz++);
	for(;n->val[n->len-1-lz]==0&&n->len-1-lz>n->sem_pos;lz++);
	n->len=n->len-lz-rz;
	n->sem_pos-=rz;
	char *v = malloc(sizeof(char)*n->len);
	for(i=0;i<n->len;i++)
	{
		v[i]=n->val[rz+i];
	}
	free(n->val);
	n->val=v;
	if(n->len==2&&n->val[0]==0&&n->val[1]==0)
	{
		n->len=1;
		n->sem_pos=0;
		n->sign=1;
	}	
	if(n->len==1&&n->val[0]==0)
	{
		n->len=1;
		n->sem_pos=0;
		n->sign=1;
	}
}
//----------------------------------------------------------
bignum *bignum_from_string(char *str)
{
	int i,j,l=strlen(str);
	bignum *ret=bignum_make_zero();
	char *ptr=str+l-1;
	ret->val=malloc(sizeof(char)*l);
	i=0; j=0; ret->sign=1;
	while(i < l)
	{
		if(*ptr>='0'&&*ptr<='9')ret->val[j++]=*ptr-'0';
		else if(*ptr==SEP)ret->sem_pos=j;
		else if(*ptr=='-')ret->sign=-1;
		ptr--; i++;
	}
	ret->len=j;
	bignum_remove_zeros(ret);
	return ret;
}
//----------------------------------------------------------
bignum *bignum_clone(bignum *n)
{
	bignum *ret = bignum_make_zero();
	memcpy(ret, n, sizeof(bignum));
	ret->val = malloc(sizeof(char) * ret->len);
	memcpy(ret->val,n->val,sizeof(char)*ret->len);
	return ret;
}
//----------------------------------------------------------
char *bignum_to_string(const bignum *n)
{
	char *ret;
	int i, j, s, d;
	s = n->len;
	s += (n->sign==-1)?1:0;
	s += (n->sem_pos>0)?1:0;
	ret=calloc(sizeof(char), sizeof(char)*(s+1));
	i = 0; j = 0;
	if(n->sign==-1) ret[i++]='-';
	while(i<s)
	{
		d=n->len-1-j++;
		ret[i++]=n->val[d]+'0';
		if(d==n->sem_pos&&n->sem_pos>0) ret[i++]=SEP;
	}
	return ret;
}
//----------------------------------------------------------
int get_max(int a, int b)
{
	return a >= b ? a : b;
}
//----------------------------------------------------------
int bignum_cmp(bignum *a, bignum *b)
{
	if(a->sign>b->sign) return -1;
	if(a->sign<b->sign) return 1;
	if(a->len-a->sem_pos<b->len-b->sem_pos) 
	{
		return a->sign*1;
	}
	if(a->len-a->sem_pos>b->len-b->sem_pos) 
	{
		return a->sign*-1;
	}
	int i,len_min=(a->len>b->len)?b->len:a->len;
	for(i=0;i<len_min;i++)
	{
		if(a->val[a->len-1-i]>b->val[b->len-1-i]) return a->sign*-1;
		if(a->val[a->len-1-i]<b->val[b->len-1-i]) return a->sign*1;
	}
	if(a->len>b->len) return a->sign*-1;
	if(a->len<b->len) return a->sign*1;
	return 0;
}
//----------------------------------------------------------
void bignum_norm_float (bignum *a, bignum *b)
{
	bignum *l, *r;
	char *val;
	int i, d;
	
	if(a->sem_pos > b->sem_pos)
	{
		r = a;
		l = b;
	}
	else
	{
		r = b;
		l = a;
	}
	d = r->sem_pos - l->sem_pos;
	val = calloc(sizeof(char), sizeof(char)*(l->len + d));
	
	i = 0;
	while(i < d)
	{
		val[i++] = 0;
	}
	while(i < l->len + d)
	{
		val[i] = l->val[i - d];
		i++;
	}
	
	l->len += d;
	l->sem_pos += d;
	free(l->val);
	l->val = val;

}
//----------------------------------------------------------
//a <- a - b (zalozenie: a > b)
void bignum_sub (bignum **a, bignum *b)
{
	
	bignum_norm_float(*a,b);
	
	int br, i, j, d;
	bignum *res;
	
	res = bignum_make_zero();
	
	res->len = (*a)->len;
	res->val = calloc(sizeof(char),sizeof(char)*res->len);
	res->sem_pos = (*a)->sem_pos;
	res->sign = (*a)->sign;
	
	br = 0;
	j = 0;
	i = 0;

	while(i < res->len)
	{
		d=(*a)->val[i]-br-(j<b->len?b->val[j]:0);
		br=(10+d<=9)?1:0;
		res->val[i]=(10*br)+d;
		i++; j++;
	}

	free((*a)->val);
	free(*a);
	
	*a = res;
	
}
//----------------------------------------------------------
//a <- a + b
void bignum_sum (bignum **a, bignum *b)
{
	bignum *res = bignum_make_zero();
	int i, j, re;
	bignum *l, *r; //l.len < r.len
	
	if((*a)->len > b->len)
	{
		r = *a;
		l = b;
	}
	else
	{
		l = *a;
		r = b;
	}

	
	res->val = calloc(sizeof(char), (r->len + 1) * sizeof(char));
	res->sem_pos = r->sem_pos;
	res->sign=r->sign;
	
	i = 0;
	re = 0.;
	
	while(i < r->len)
	{
		res->val[i] = r->val[i] + ((i<l->len)?l->val[i]:0) + re;
		re = (res->val[i]>9)?1:0;
		res->val[i] %= 10;
		i++;
	}
	
	res->val[i] = re;
	res->len = r->len + re;
	
	free((*a)->val);
	free(*a);
	
	*a = res;
	
}
//----------------------------------------------------------
void bignum_sub_sign(bignum **a, bignum *b)
{
	bignum_norm_float(*a,b);
	if(bignum_cmp(*a,b)==1)
	{
		bignum *tmp=bignum_clone(b);
		bignum_sub(&tmp,*a);
		tmp->sign=-1;
		free((*a)->val);
		free(*a);
		*a=tmp;
	}
	else
	{
		bignum_sub(a,b);
	}
}
//----------------------------------------------------------
void bignum_add_sign(bignum **a, bignum **b)
{
	if((*a)->sign != (*b)->sign)
	{
		int as=(*a)->sign,bs=(*b)->sign;
		(*a)->sign=1;
		(*b)->sign=1;
		as=(bignum_cmp(*a,*b)==-1)?as:bs;
		bignum_sub_sign(a, *b);
		(*a)->sign=as;
		bignum_remove_zeros(*a);
		return;
	}
	
	bignum_norm_float(*a,*b);
	if(bignum_cmp(*a,*b)==1)
	{
		bignum *tmp=bignum_clone(*b);
		bignum_sum(&tmp,*a);
		free((*a)->val);
		free(*a);
		*a=tmp;
	}
	else
	{
		bignum_sum(a,*b);
	}
	bignum_remove_zeros(*a);
	bignum_remove_zeros(*b);
}
//----------------------------------------------------------
void multiple_decimal(decimal &a, decimal &b)
{
}
//----------------------------------------------------------
//only positive numbers
//a <- a + b
void decimal_sum_positive(decimal &a, decimal &b)
{
	int p = 0, i;
	
	if(cmp_decimal(a, b) == 0)
	{
		a.integer = 0;
		a.fraction = 0;
		sign = 1;
	} 
	else
	{
		if(strlen(a) >= strlen(b))
		{
			
		}
		else
		{
			char * tmp = (char*)malloc(strlen(b) * (sizeof(char) + 1));
			memcpy(tmp, b.fraction, strlen(b) * (sizeof(char) + 1));
			free(a.fraction);
			a.fraction = tmp;
		}
	}
}
//----------------------------------------------------------
int main()
{
	char str1[1000], *str2;
	bignum *n1, *n2;
	int n;
	
	n1=bignum_from_string("0");
	
	scanf("%d",&n);
	
	while(n--)
	{
		scanf("%s",str1);
		n2=bignum_from_string(str1);
		bignum_add_sign(&n1,&n2);
		str2=bignum_to_string(n1);
		free(n2);
	}
	
	printf("%s\n",bignum_to_string(n1));
	
	return 0;
	
	scanf("%s %s", str1, str2);
	n1 = bignum_from_string(str1);
	n2 = bignum_from_string(str2);
	
	bignum_add_sign(&n1,&n2);
	printf("bignum n1:\nlen=\t%d\nsig=\t%d\nsem_pos=\t%d\nval=\t%s\n", n1->len, n1->sign, n1->sem_pos, bignum_to_string(n1));
	printf("bignum n2:\nlen=\t%d\nsig=\t%d\nsem_pos=\t%d\nval=\t%s\n", n2->len, n1->sign, n1->sem_pos, bignum_to_string(n2));
	int cmp = bignum_cmp(n1,n2);
	if(cmp == 1) printf("a < b\n");
	if(cmp == -1) printf("a > b\n");
	if(cmp == 0) printf("a == b\n");
		
	return 0;
}
